package com.level2app.ui.app;

import android.graphics.Paint;

import com.level2app.R;
import com.level2app.base.BaseFragment;
import com.level2app.base.BaseViewModel;
import com.level2app.databinding.FragmentAccountBinding;
import com.level2app.ui.account.HelpAndSupportActivity;
import com.level2app.ui.account.LegalActivity;
import com.level2app.ui.account.SettingsActivity;
import com.level2app.ui.account.AccountDetailsActivity;
import com.level2app.utils.JumpIntent;
import com.level2app.utils.ToastHelper;
import com.level2app.view.dialog.ChooseHeadDialog;

public class AccountFragment extends BaseFragment<FragmentAccountBinding, BaseViewModel> {

    @Override
    protected BaseViewModel bindModel() {
        return getViewModel(this, BaseViewModel.class);
    }

    @Override
    protected void initInject() {
        getFragmentComponent().inject(this);
    }

    @Override
    protected void initData() {
        binding.reactivateTv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        binding.reactivateTv.getPaint().setAntiAlias(true);

        // 当用户粉丝数不满足要求，creator 皇冠变灰，然后显示reactivate
        if (true) {
            binding.headerRightIv.setImageResource(R.mipmap.icon_header_right_blue);
            binding.reactivateTv.setText(getString(R.string.reactivate));
        } else {
            binding.headerRightIv.setImageResource(R.mipmap.icon_header_right_grey);
        }

        // 不是creator，会显示Become a creator，并且三个social icon置灰。
        binding.reactivateTv.setText(getString(R.string.become_a_creator));
        binding.youToBeIv.setImageResource(R.mipmap.icon_you_to_be_def);
        binding.insIv.setImageResource(R.mipmap.icon_ins_def);
        binding.tikTokIv.setImageResource(R.mipmap.icon_tik_tok_def);

        // icon_you_to_be(YouTuBe)/icon_ins(ins)/icon_tik_tok(TikTok)
    }

    @Override
    protected void initClick() {
        viewModel.onDelayClick(binding.headIv, o -> {
            ChooseHeadDialog chooseHeadDialog = new ChooseHeadDialog(mContext) {
                @Override
                public void takePhoto() {

                }

                @Override
                public void choosePhoto() {

                }
            };
            chooseHeadDialog.show();
        });

        viewModel.onDelayClick(binding.editIv, o -> {
            JumpIntent.jump(getActivity(), AccountDetailsActivity.class);
        });

        viewModel.onDelayClick(binding.reactivateTv, o -> {
            ToastHelper.showToast("reactivate");
        });

        viewModel.onDelayClick(binding.settingsLl, o -> JumpIntent.jump(getActivity(), SettingsActivity.class));

        viewModel.onDelayClick(binding.legalLl, o -> JumpIntent.jump(getActivity(), LegalActivity.class));

        viewModel.onDelayClick(binding.helpLl, o -> JumpIntent.jump(getActivity(), HelpAndSupportActivity.class));

        viewModel.onDelayClick(binding.logOutTv, o -> {
            ToastHelper.showToast("Log out");
        });
    }
}
